import requests
import xlrd,xlwt
list_all=[]
url_string = r'https://douban.uieee.com/v2/movie/in_theaters'
response = requests.get(url_string)
obj = response.json()
move_list = obj['subjects']
for item in move_list:
    list=[]
    list_name = []
    list.append(item['title'])
    list.append(item['genres'])
    list.append(item['rating']['average'])
    for j in item['casts']:
        list_name.append(j['name'])
    list.append(list_name)
    list.append(item['durations'])
    list_all.append(list)
for i in list_all:
    print(i)
wbt = xlwt.Workbook()
sheet = wbt.add_sheet('内容')
tilte_list=['电影名称','电影类别','电影评分','电影主演','电影时间']
title=0
for zy in tilte_list:
    sheet.write(0, title, zy)
    title+=1
x = 1
for m in list_all:
    y=0
    for n in m:
        if type(n)==list:
            str=''
            for q in n:
                str+=q
            sheet.write(x,y,str)
        else:
            sheet.write(x,y,n)
        y+=1
    x+=1
wbt.save('db.xls')